Skip to content

perf(sharing): ask record sharing for the write verdicts of a predicate write's candidates as one set - #37558

Draft
objectstack-fleet[bot] wants to merge 8 commits into
mainfrom
claude/issue-35934-sharing-bulk-write-scope
Draft

objectstack-fleet[bot] wants to merge 8 commits into
mainfrom
claude/issue-35934-sharing-bulk-write-scope

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread

repo:objectstack#5 · os-bill · session_01Utp6CbdHk3orAeensH6EzS

Fixes #35934
Ruling-ref: 7190344023
Clause-②: yes (widening)
Metadata-protocol: none

维护者速读

  • 用户看到什么变化:成员或「修改全部」管理员按条件批量改、删上万条记录时,速度从几秒降到零点几秒;改哪些行、删哪些行与之前完全一样。
  • 为什么做:属于「记录共享与权限性能」这一组工作,解决批量写入时权限检查逐行读库、读数随行数增长的问题。
  • 出错会怎样:最坏情况是批量写入里本该放行的行被拒(查询失败一律按拒绝处理,不会多放行);新能力是可选的,撤回本次改动即恢复逐行检查。
  • 要你做什么:新增的两个接口名称在你的否决窗口内,请确认或否决命名。

What changes

ISharingService (packages/spec/src/contracts/sharing-service.ts) gains two OPTIONAL members, as ruled (option C):

  • checkEditMany(object, recordIds, context) and checkDeleteMany(object, recordIds, context).
  • Each answers SharingWriteVerdict[]: answer i is the verdict checkEdit / checkDelete answers for recordIds[i] (same length, same order, repeats kept).
  • Same bases, same order of decision, same verb boundary: an edit share is allow to checkEditMany and deny to checkDeleteMany.
  • A chunk whose lookup fails answers deny for each of its records, never abstain.
  • Name and precedent: checkEdit / checkDelete on this same contract, plus the data protocol's …Many suffix (IDataDriver.updateMany? / deleteMany?, both optional). Two members rather than one with a verb argument, because this contract already splits the write verdict by verb.

SharingService (plugin-sharing) implements both. checkEdit / checkDelete are now the one-record case of the same private writeVerdicts:

  • Object-level decisions (bypass list, schema, OWD, owner field, principal) are made once per call.
  • Ids are read in chunks of 1,000 (WRITE_VERDICT_CHUNK; the docblock gives the dialect bounds: Oracle's 1,000-item IN list, SQL Server's 2,100 parameters).
  • Per chunk: one read of the rows (owner, and queue plus organization when the object has an ownership queue column), and for an update one read of the caller's write-level shares.
  • The owner set, each queue membership and the Modify All probe are resolved at most once per call.
  • A single record costs the reads it always did. One exception: an update on an object with an ownership queue column now reads the row once instead of twice (queue and owner in one read).

SecurityPlugin (plugin-security) feature-detects the set form on the kernel's sharing service on the predicate write floor relief (#35802 / #35914):

  • If the set form is there: one set-form call for the candidates the platform floor does not admit, with one context built once (__writeScope, the external grant patch). An answer that is not allow or deny normalises to abstain. A probe that throws, or a list of the wrong length, gives deny for all, with one error logged.
  • If it is not there: per row, 25 at a time, exactly as before.
  • Delegated callers are still not asked.
  • Which rows are written is unchanged either way.

Not in this PR (as ordered): the 2a authored-scope change. Untouched: ADR-0155, buildWriteFilter and every find.

Changeset: patch for @objectstack/spec, @objectstack/plugin-sharing and @objectstack/plugin-security. Rule read: AGENTS.md Post-Task Checklist 3. Kind none gives patch, and an optional, non-protocol contract widening ships patch.

Tests

Measured on SQLite, N = 10,000 rows owned by another user. The bench is the kept one from report 7187608580, extended with set-form counting and a per-row mode. It is uncommitted, as ordered. Set form is this branch; per-row is the same branch without the set members; main is the report's readings.

case main per-row on this branch set form
member predicate update 20,004 reads · 6,013 ms 20,004 · 6,603 ms 24 reads · 270 ms
member predicate delete 10,003 reads · 2,178 ms 10,003 · 1,957 ms 13 reads · 111 ms
Modify All predicate update (10,000 written) 10,004 reads · 1,880 ms 10,004 · 1,765 ms 14 reads · 242 ms
  • Set mode made one set call per write, with at most one bypass probe (per row: 10,000).
  • The per-row reads equal main's, so the by-id path gained no read.

New pins:

  • plugin-sharing/src/sharing-service.test.ts, equivalence: checkEditMany / checkDeleteMany equal checkEdit / checkDelete on every row.
    • Objects × callers × verbs: private with a queue column, public read/write, no owner field, phantom owner anchor, shares inert, unknown object.
    • Callers: member, unit depth, Modify All at own and org depth, delegated, principal-less, guest, system.
    • Rows: own, owner-not-creator, created-not-owned, edit-shared, read-shared, queue mine / not mine / other org, ownerless, missing.
    • Also: the empty list, and order with repeats.
  • Same file, counted reads: 10,000 records give 10 row reads, 10 share reads, 1 bypass probe and 1 owner set; a delete makes 0 share reads. A per-row control of 300 rows gives 300 / 200 / 100. A queue membership is asked once over 2,500 rows.
  • Same file, fail-closed: 1,500 ids with a failing second chunk give 500 deny and one log line. A share read that throws denies its whole chunk, owned rows included.
  • plugin-security/src/predicate-write-floor-deferral.test.ts, feature-detect:

Ablations: each one was committed first, mutated through scripts/ablation-replace.mjs, and restored (blob equals HEAD, git status clean).

  1. Share membership emptied: 7 equivalence cases red.
  2. The chunk catch answers abstain: 2 fail-closed cases red.
  3. WRITE_VERDICT_CHUNK = 1: 2 counted-reads cases red.
  4. Feature-detect return null changed to return []: 10 plugin-security cases red.

Acceptance notes

Verification

  • Two minutes: pnpm --filter @objectstack/plugin-sharing exec vitest run --maxWorkers=2 src/sharing-service.test.ts -t "35934". Expect every [#35934] case green, including 10,000 records: two reads per chunk of 1,000.
  • Read first, by risk:
    1. plugin-sharing/src/sharing-service.ts, writeVerdicts: the per-row order inside the chunk loop, and the try per chunk.
    2. plugin-security/src/security-plugin-sharing-verdicts.ts, resolveSharingWriteVerdicts: normalisation and the length check.
    3. packages/spec/src/contracts/sharing-service.ts: the member docblocks.

Local runs at the final head 14bf9f91, through scripts/pm/os-verify-lock.sh:

  • plugin-sharing: pnpm test gives 78 files, 1,748 passed / 11 skipped. Typecheck passed. sharing-service.test.ts was re-run after the last commit: 289 passed.
  • plugin-security: pnpm test gives 290 files, 7,330 passed / 45 skipped. Typecheck passed. Run at c6f613be; the last commit touched only a plugin-sharing test file.
  • spec: src/contracts/sharing-service.test.ts gives 15 passed, and check:generated reports all 14 artefacts up to date.
  • Dogfood: the dependency closure was built, then the nine files that judge the sharing write paths were run. 9 files, 110 tests passed. The files: authored-row-write-scope, bulk-widener-probe, owd-public-read-write-write-floor, showcase-scope-depth-write, federated-phantom-share-grant, direct-share-grant-is-manual, cbp-parent-attachment-comment-gates, predicate-write-unreadable-not-matched, armed.
Derived gate families: 95 derived, 95 run
  • node scripts/pm/dispatch-gates.mjs --commands gives 95 commands. The list is the same at c6f613be and at 14bf9f91. The --ran reconciliation reports 95 run, 0 NOT-MEASURED, 0 UNRUN.
  • The full run was at c6f613be: 92 exited 0 and 3 exited 1.
    • check:dts-closure and check:dual-build-cjs-loads went red while a concurrent closure build of mine had packages/plugins/organizations/dist half-written. Re-run after the build: both exit 0 (267/267 declaration files; 127 require entry points load).
    • check:where-matcher was a real finding: the new engine double read a where combinator as a field name. Fixed in 14bf9f91 (the double now refuses a combinator), and the gate exits 0.
  • 20 families that read test files were re-run at 14bf9f91, and all 20 exited 0: where-matcher, objectql-double-limit, engine-double-contract, nul-bytes, test-source-alias, type-check-debt, cross-package-test-inputs, query-options-erasure, refd-timer-probe and eleven more.
  • Local-only check:dev-prereqs scan: NOT MEASURED (--self-test passed). This box has 35 unrelated @object-ui packages unbuilt, and the scan judges the whole workspace.
  • node scripts/pm/overlap-check.mjs --branch=HEAD at 14bf9f91 gives VERDICT clean: it merges cleanly with origin/main 1af67b26, and no open pull request head shares a file.

🤖 Generated with Claude Code

… record ids

checkEditMany / checkDeleteMany on the contract (optional), one
implementation in SharingService behind both the by-id and the set
form, and plugin-security's predicate write asks the set form where the
service serves it.

Claude-Session: https://claude.ai/code/session_01Utp6CbdHk3orAeensH6EzS
Co-authored-by: Claude <noreply@anthropic.com>
…dict

Equivalence over the record-sharing matrix, counted reads per chunk,
fail-closed per chunk, and plugin-security's feature-detect of the set
form over the predicate-write matrix.

Claude-Session: https://claude.ai/code/session_01Utp6CbdHk3orAeensH6EzS
Co-authored-by: Claude <noreply@anthropic.com>
…bound after its filter

check:objectql-double-limit could not drive the double; its find now
filters a plain store and slices by limit only when one is given, and
the read counting sits outside the store's answer.

Claude-Session: https://claude.ai/code/session_01Utp6CbdHk3orAeensH6EzS
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/plugin-security, @objectstack/plugin-sharing, @objectstack/spec, touching 61 documentable anchor(s).

23 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 411646562566a1e12b4e0fc3de256192e8302719.

⛔ 11 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 anchor(s) matched too much of the corpus to be a work list: organization_id (literal, 43 pages)
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 180 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 411646562566a1e12b4e0fc3de256192e8302719 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from a018ddcc6c3c5d6c62342a53fc0bdb8002ae7971 — the merge of head bd194d3ffcc734a0c0feb32dc86166ba97a12cd5 into base 411646562566a1e12b4e0fc3de256192e8302719, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin a018ddcc6c3c5d6c62342a53fc0bdb8002ae7971 && git checkout a018ddcc6c3c5d6c62342a53fc0bdb8002ae7971
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 411646562566a1e12b4e0fc3de256192e8302719 bd194d3ffcc734a0c0feb32dc86166ba97a12cd5 && git checkout -B drift-repro 411646562566a1e12b4e0fc3de256192e8302719 && git merge --no-ff bd194d3ffcc734a0c0feb32dc86166ba97a12cd5

node scripts/docs-audit/affected-docs.mjs --json 411646562566a1e12b4e0fc3de256192e8302719

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 411646562566a1e12b4e0fc3de256192e8302719 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbdHk3orAeensH6EzS

Final head for L1 + contract review · area o5-D · 2026-11-26T13:16Z
Head-sha: 14bf9f91364c962a6dc96e3e66272c95ed29e14d
Check-runs at this head when written: 12 success, 10 skipped, 24 in progress, 0 failure. Draft.
Diff: +965 −116 in 9 files. ISharingService gains the optional checkEditMany / checkDeleteMany (spec contracts/sharing-service.ts). SharingService implements both through one private writeVerdicts, and checkEdit / checkDelete become its one-id case. plugin-security's predicate write floor relief feature-detects the set form. Changeset patch ×3. Clause-②: yes (widening) · Metadata-protocol: none · Ruling-ref: 7190344023 (option C). Not governed. Contract face: packages/spec/src/contracts/**, so a CONTRACT_REVIEW_TIER record is owed.
Evidence (os-dev report 7193076972):

  • P0: premises 1 to 9 of 7187970489 re-read at 54ea3c8c.
  • P1 holds: a 1,000-id chunk costs 2 sharing reads, and no row class needs a per-row read.
  • Bench at 10,000 rows, reads and time, main → set form:
    • member update: 20,004 / 6,013 ms → 24 / 270 ms;
    • member delete: 10,003 / 2,178 ms → 13 / 111 ms;
    • Modify All update: 10,004 / 1,880 ms → 14 / 242 ms.
      The per-row fallback equals main.
  • Pins: equivalence over the ruled matrix (every object × caller × verb × row class), counted reads, fail-closed per chunk, and feature-detect. Four ablations, each red.
  • plugin-sharing 1748 and plugin-security 7330 tests green. The 9 sharing write-path dogfood files pass 110/110. dispatch-gates reconciliation: 95 derived, 95 run. Overlap: clean.
    For the reviewer to weigh:
  • The member name follows precedent: checkEdit / checkDelete plus the data protocol's optional …Many (updateMany? / deleteMany?). It is two members rather than a verb argument because the contract already splits the verdict by verb. This is under the maintainer's veto window.
  • The changeset level is patch for an optional contract member (AGENTS.md Post-Task Checklist 3, kind none).
  • Out of scope, not filed:
    • content/docs/kernel/runtime-services/sharing-service.mdx lists only canEdit / canDelete, not the tri-state members or the new set members.
    • The pending .changeset/35802-predicate-write-floor-deferral.md (lines 23–27) states the per-row cost this PR supersedes in the same release. Editing it needs a deliberate-correction declaration, so that is the seat's call.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 14bf9f9 · 2026-11-26T13:17Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 14bf9f91364c962a6dc96e3e66272c95ed29e14d
Local-runs: none
Scope: packages/spec/src/contracts/sharing-service.ts + packages/plugins/plugin-sharing/src/sharing-service.ts, packages/plugins/plugin-security/src/security-plugin-sharing-verdicts.ts, packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts, packages/plugins/plugin-security/src/security-plugin.ts

Security-touching: this is the record-sharing write gate and the predicate write's floor decision (authorization). It was judged on one question first: can the set form answer allow where the per-row gate would not. By reading, it cannot.

Check-runs on this head when read: 20 success, 11 skipped, 34 in progress, 0 failed. The PR is a draft. Every Test Core shard, Build Core and the workspace type check were still running, so this PASS is the design verdict only; it weighs no red gate because none had concluded. Do not queue before those runs end green.

① Derived judgments

  • Public surface: ISharingService gains two optional members, checkEditMany and checkDeleteMany, each (object, recordIds, context) answering SharingWriteVerdict[]. Right. No existing member, type or export changes shape. No write-scope member (buildWriteFilter) is added, as ruling 7190344023 (option C) requires.
  • Accept set: unchanged. No authorable key or schema moves, and Metadata-protocol: none is right.
  • Rows written: unchanged by design. Plugin-security drops the floor for exactly the ids whose verdict is allow, as before; the sharing middleware's own write scope is untouched.
  • Behaviour that does move, all in the closed direction:
    • A fault now denies a whole chunk (up to 1,000 ids), or the whole list at the plugin-security seam, where the per-row path denied one row. This is the ruled term.
    • By id, an update on an object with a queue column reads the row once, not twice. No by-id path gains a read.
  • docs/adr/** and skills/** are not in the diff. ADR-0155 is untouched, and no leaf is put in any find.

② Semver level

Clause-②: yes (widening). Right: an additive optional member on a published contract. The line is in both the PR body and the changeset.

patch on @objectstack/spec, @objectstack/plugin-sharing and @objectstack/plugin-security is right under AGENTS.md Post-Task Checklist 3: kind none takes patch, and a non-protocol widening ships patch. All three packages are moved by the diff. No BREAKING banner or ADR-0087 marker is owed.

One observation for the lane seat, not graded here: the changeset's "from 20,004 store reads and 6.6 s" is the per-row run on this branch (6,603 ms). The same case on main read 6,013 ms, and the #35802 changeset says 5.3 s. The read counts agree everywhere.

③ Boundary flags

  • Dev report 7193076972 carries no open_questions and security_findings: none. Its four deviations (no empty-branch probe, check:dev-prereqs not measured, ablation 4 run before the merge, bench uncommitted) do not touch the contract. Accepted.
  • Member names, under the maintainer's veto window: checkEditMany / checkDeleteMany follow the ruled precedent (checkEdit / checkDelete plus the data protocol's optional …Many). Two members, not one with a verb argument, matches how this contract already splits the verdict. No objection; the veto stays the maintainer's.
  • SQL push-down (Prime Directive 5): no finding. The set form materialises no new ids: it is handed the candidate list plugin-security already holds and already binds into the write. Per chunk it makes one id IN (…) read and, for update, one record_id IN (…) read. The alternative push-down, the share semi-join leaf in a find, is what ADR-0155 Q3 forbids and ruling C rules out. The owner match is done in the app against an owner set resolved once, because the tri-state needs per-id facts (missing row, null owner, queue) that a filtered read would hide. Reason given.
  • Ruled premise (at most two store reads per chunk plus one bypass probe per call, chunk of at least 1,000): holds by reading. Outside the chunk loop the call adds one owner-set resolution and one membership lookup per distinct (queue, organization); neither grows per row. The 24-read figure follows (10 chunks × 2, plus the write's own 4). The timings were not re-measured.
  • WRITE_VERDICT_CHUNK docblock: the Oracle and SQL Server bounds it cites were not verified in the driver. The chunk is within both as stated, so nothing depends on it.
  • Out-of-scope question 1, the docs gap: real. content/docs/kernel/runtime-services/sharing-service.mdx lists buildReadFilter, canEdit, canDelete and canManageShares only. It has never listed checkEdit / checkDelete (a gap since ISharingService 写判定补三态(放行/不表态/拒绝)—— #5492 裁决 B 案的 step1,二态 canEdit 已实测产出 fail-open #6428), and this PR adds two more unlisted members. It is outside the card's file surface. File a docs follow-up that adds the tri-state members and the set form together.
  • Out-of-scope question 2, .changeset/35802-predicate-write-floor-deferral.md: its cost paragraph ("one sharing verdict, a few store reads, for each matched row", and the 1,000 / 10,000-row figures) is now stale for the bundled sharing service, and both changesets ship in the same release. It stays true only for a sharing service without the set form. Not wrong enough to block: this PR's changeset states the new cost and names the old figures as "went from". Recommended: a dedicated correction of that paragraph before the release consumes it, saying the per-row cost applies where the service serves no set form. That edit needs the seat's deliberate-correction declaration, so it is the seat's call, not a rider here.
  • 2a (card sharing: a predicate bulk write also honours app-authored update/delete policies (authored scope ORed into the middleware bulk write scope) #37535) is not in this diff. Right.

④ Design judgment

No must-fix, no should-fix.

packages/spec/src/contracts/sharing-service.ts against ruling 7190344023. Holds, term by term:

  • Set form of the write verdict, per id the same tri-state: answer[i] is the verdict for recordIds[i], same length, same order.
  • No write-scope member.
  • Optional, feature-detected, per-row fallback with the same answers.
  • The service owns the chunking.
  • A chunk whose lookup throws is deny, never abstain.
  • The delete form carries the verb boundary (ADR-0111 D3).

Both docblocks name the modifyAllRecords bypass, which the spec parity test now requires of them.

plugin-sharing/src/sharing-service.ts against the contract. I tried to break the equality between writeVerdicts over a list and the per-row gate on main, class by class:

  • One implementation: checkEdit / checkDelete are writeVerdicts over one id. I compared that one-id path with main's bodies line by line. The decision order is the same: system allow, bypass-listed abstain, no schema abstain, queue (update only) before the open-OWD abstain, no owner field abstain, no principal deny, owner at write depth, write-level share (update only, and only where grants count), Modify All last.
  • Owner and role hierarchy: the same matchesOwnerScope, with the owner set resolved once per call. org depth still needs a row with an owner.
  • Sharing rules, manual shares, teams: the gate reads user-recipient rows at edit / full only, exactly as main does, so whatever is materialised to such a row counts in both forms and nothing else counts in either. The list read has no limit, and neither the engine nor a driver adds a default one, so several grant rows per record cannot truncate it.
  • public_read_write and no-owner objects: decided once per call. With a queue column the rows are still read first, so a queue allow still wins over the abstain.
  • Missing or deleted ids: no row, so no owner and no queue; the share and the bypass still decide, as per row.
  • Duplicate ids: each index gets its own verdict. The row read's limit is the chunk length, which is at least the number of distinct ids.
  • Mixed objects: not expressible, since a call names one object.
  • Boundaries: 1,000 ids is one chunk. 1,001 is a chunk of 1,000 and a chunk of one, and the chunk of one takes the by-id read (where { id }, limit: 1). An empty list answers [] before any read.
  • System context: allow for every id. A bypass-listed object: abstain for every id.
  • Faults: a failure in the object-level tests denies every id the queue basis does not admit, which is what the per-row gate did. A thrown chunk read or share read denies that chunk. A thrown bypass lookup denies the ids still waiting.
  • No path produces an allow the per-row gate would not: every allow comes from the same four tests on the same row, and the row and share lookups key on the exact id.

plugin-security/src/security-plugin-sharing-verdicts.ts (and the two host-wiring files) against the contract:

  • Feature-detect is per verb, with typeof … === 'function'. Absent, the function answers null and the unchanged per-row loop runs (25 at a time, through resolvePreImageFloorDrop). A host double without resolveKernelService also falls back.
  • The set path makes the same floor test once, builds the same context (__writeScope, the external grant patch), passes ids as strings as the per-row path does, and drops exactly the allow ids.
  • An answer that is neither allow nor deny normalises to abstain. A throw or a wrong-length list is deny for all, logged once.
  • Delegated callers are still not asked.

Nits. None changes a verdict on a path the tree reaches. N1 and N2 are worth a follow-up card; N3 and N4 can stay.

  • N1 (nit) — the set form maps rows and shares back by exact id string, while the per-row gate takes whatever row the store's = returns. On a store that compares ids case-insensitively or pads spaces (MySQL's default collation), an id handed in a different spelling from the stored one finds its row per row and counts as missing in a set, so an owned row answers deny there. This is closed-direction only. The one in-tree caller passes ids it read from the store, so it does not reach this. Either note it in the docblock ("ids as the store returns them") or normalise.
  • N2 (nit) — the owner-set and queue-membership promises are memoised for the call, a rejected one included. A transient failure in one chunk therefore denies every later chunk that needs the same lookup, where the per-row gate would ask again. Closed direction. The writeVerdicts docblock's "the other chunks keep their answers" is slightly too strong.
  • N3 (nit) — the checkEditMany docblock's allow list names the queue basis and omits system context; the checkEdit docblock it points to names system context and omits the queue basis. The equality sentence governs, and the code agrees with both, but the two lists should match.
  • N4 (nit) — the header of security-plugin-sharing-verdicts.ts still says exactly one function there is not a moved method body, and its list does not name resolveSharingWriteVerdicts.

For the lane seat (tests are its ACCEPT): the equivalence pin compares the set form with checkEdit, which is now the same function over one id, on an engine double. So it pins the list path against the one-id path. Equality with main's per-row gate rests on the existing checkEdit / checkDelete suite, and on the real-SQLite rig in plugin-security, which is small (4 and 60 rows). No case sits at exactly 1,001 ids; I read that path and it is correct.

Implemented-by: claude/issue-35934-sharing-bulk-write-scope
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

席位核对

Head-sha: 14bf9f91364c962a6dc96e3e66272c95ed29e14d
ACCEPT — L1, seat repo:objectstack#5

  1. Shape: open draft against main, Fixes #35934. 9 files, +965/−116, ≤ 3000. Not governed, and no narrowing declared. Clause-②: yes (widening) on packages/spec/src/contracts, Metadata-protocol: none, all three packages at patch. The face is packages/spec/src/contracts/sharing-service.ts at CONTRACT_REVIEW_TIER. Security-touching (sharing and authorization), so the seat adds the security label.
  2. Premise: this implements the maintainer's ruling C (7190344023). ISharingService gains optional checkEditMany / checkDeleteMany. There is no write-scope member, and ADR-0155 is untouched. checkEdit / checkDelete are now the one-id case of the same writeVerdicts, with main's decision order. Every difference the reviewer found leans toward deny. A service without the methods falls back, per verb, to the unchanged per-row loop. Cost: two reads per 1,000-id chunk.
  3. Gates: contract record 7193294421 (CONTRACT_REVIEW_TIER, verified on the transcript) reads PASS, with no must-fix and no should-fix. The equivalence-matrix pin and 4 ablations each went red (os-dev report 7193076972). CI was still running when the record was read: 20 success, 11 skipped, 0 failed, 34 in progress.
  4. Accepted deviations: N1–N4 as in the record (id spelling on case-insensitive stores, memoised rejected lookups, the docblock allow-lists disagreeing, a stale module header). The changeset's "6.6 s" is this branch's per-row run; main read 6.0 s. No test sits at exactly 1,001 ids; the reviewer read that path and found it correct.
  5. Out of scope and where it went: Sharing service docs: list the tri-state write verdicts and the set form; correct the per-row cost in changeset 35802 #37563 (under 专题:共享授权与字段权限改造(「查看/修改全部」只管记录不管字段;共享授权在数据库里判断,读写一致,没有 5000 条上限) #36232): the sharing-service.mdx docs gap, and the stale per-row cost paragraph in .changeset/35802, which must be corrected before the release that carries both. sharing: a predicate bulk write also honours app-authored update/delete policies (authored scope ORed into the middleware bulk write scope) #37535 (ruling 2a) unblocks when this merges.
  6. Landing terms: ungoverned, default tier. Area o5-D lands it with --land once every required check on 14bf9f9136 is green. A red check is a REWORK, not a re-run.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Security label: the sharing write verdicts gate edit and delete (contract record 7193294421; no security finding, and every difference leans toward deny).

…a Set

The 10,000-record pin spent 709 of its 736 ms in the double, which rebuilt
and scanned each $in list once per row; under CI shard load that passed the
5 s test timeout. Each list is now a Set built once, so a read costs the rows
it scans plus the ids it names. The counted-read assertions are unchanged.

Claude-Session: https://claude.ai/code/session_01Utp6CbdHk3orAeensH6EzS
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head bd194d3 · 2026-11-26T13:58Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: bd194d3ffcc734a0c0feb32dc86166ba97a12cd5
Local-runs: none
Scope: packages/spec/src/contracts/sharing-service.ts + packages/plugins/plugin-sharing/src/sharing-service.ts, packages/plugins/plugin-security/src/security-plugin-sharing-verdicts.ts, packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts, packages/plugins/plugin-security/src/security-plugin.ts

Delta round on record 7193294421 (PASS at 14bf9f91). The new head is one commit on 14bf9f91 and touches one file, packages/plugins/plugin-sharing/src/sharing-service.test.ts (+11/−1). No file in Scope moved, so the earlier ①, ② and ④ stand as written. The earlier record had no must-fix and no should-fix, so there is no id to close.

Security-touching (sharing and authorization), as before. The delta changes a test double only; no verdict path moved.

Check-runs on this head when read: 12 success, 10 skipped, 14 in progress, 0 failed. The PR is a draft. The Test Core shards had not started (their plan job was still running), so the shard that timed out on 14bf9f91 has not been re-answered yet. Build Core, the four type checks and the lint families that carry check:where-matcher were also still running. This PASS is the design verdict; do not queue before those runs end green.

① Derived judgments

Unchanged. The delta publishes nothing: no source file, contract member, export or accept set moves.

② Semver level

Clause-②: yes (widening). Unchanged. The changeset is untouched and patch on the three packages still matches what the diff publishes. A test-only commit owes no further changeset.

③ Boundary flags

  • Addendum 7194072292 carries no open question, deviations: none and security_findings: none. Its cause reading is consistent with the code: the double filtered each chunk's rows by rebuilding and scanning the $in list once per row, so a 1,000-id chunk cost about a million comparisons.
  • SQL push-down: not applicable. No read in the service changed.
  • The two out-of-scope answers in the earlier record (the sharing-service.mdx docs gap, and the stale cost paragraph in .changeset/35802-predicate-write-floor-deferral.md) are unchanged.

④ Design judgment

No must-fix, no should-fix.

The three points asked, by reading the delta and the double at the new head:

  • The Set cache does not weaken the pins. valueMatches did listOf(wanted).includes(key) and now does new Set(listOf(wanted)).has(key), cached. Both derive from the same listOf and the same keyOf, so membership is identical for every input:
    • an $in list, with or without repeats;
    • an object with no $in, or an array: an empty list before, an empty Set now, so no match either way;
    • a scalar or null: the actual === wanted branch, untouched.
      The double therefore matches exactly the rows it matched at 14bf9f91. Its distance from the real engine's $in (ids compared as strings) is the same as before, not new.
  • Stale-cache risk: none reachable. The WeakMap is keyed by the where leaf object (the { $in: […] } wrapper), not by the array inside it. A stale answer would need the same leaf object handed to two finds with its array mutated in between. The double is reached only through SharingService, which builds a fresh where literal and a fresh spread copy of the ids for every find, so each read gets its own key. The cache lives per makeVerdictEngine call, so nothing carries across rigs.
  • Counted reads and the where-matcher gate are unchanged. noteRead, rowsNamed, the read counters and every assertion in the counted-reads and fail-closed cases are byte-identical to 14bf9f91. The combinator refusal in storeFind is untouched. No timeout was added.
  • Ablation 3 still goes red on reads. Not run here (read-only). By reading: with WRITE_VERDICT_CHUNK = 1 every chunk takes the one-id read, a scalar where { id } that the double answers by lookup, so the 10,000-record case finishes quickly and fails on reads being 10,000 where 10 is expected, and the queue case on 2,500 where 3 is expected. That agrees with the addendum's account (4 cases red, all on assertions).

One nit, new in this round:

  • N5 (nit) — the cache comment and the addendum say "per list", but the key is the leaf object that holds the list. A future test that reuses one where object and mutates its array would read a stale Set. Nothing does so today. A word in the comment would cover it.

N1 to N4 of the earlier record are untouched by this commit and stand as nits.

Implemented-by: claude/issue-35934-sharing-bulk-write-scope
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

席位核对

Head-sha: bd194d3ffcc734a0c0feb32dc86166ba97a12cd5
ACCEPT — L1, seat repo:objectstack#5, delta round 1 (test-only)

  1. Shape: one commit on 14bf9f91 (ACCEPTed in 7193353172). It touches only sharing-service.test.ts (+11/−1). Declarations, security label and landing class are unchanged.
  2. Premise: the red Test Core 9/10 at 14bf9f91 was the test double's own cost. Its `` match rebuilt and scanned the list once per row. It now tests against a Set cached per where-leaf, so membership is identical for every input, and no timeout was added. The counted-read and fail-closed assertions and the where-matcher gate are byte-identical. Ablation 3 goes red on reads, not on time (addendum 7194072292 on sharing: a predicate write asks one write verdict per candidate row, so a member bulk update over 10,000 rows owned by others costs ~5 s for no extra row; give ISharingService a bulk write-scope and verdict contract #35934).
  3. Gates: delta record 7194156298 (same reviewer, CONTRACT_REVIEW_TIER, verified on the transcript) reads PASS. When it was read, CI on this head showed 12 success, 10 skipped, 14 in progress and 0 failed; the Test Core shards had not run yet.
  4. Accepted deviations: N1–N4 as before, plus N5: the cache comment says "per list", but the key is the where-leaf object. The PR body's Tests section still cites 14bf9f91; refresh it when convenient.
  5. Out of scope and where it went: Sharing service docs: list the tri-state write verdicts and the set form; correct the per-row cost in changeset 35802 #37563, as before.
  6. Landing terms: ungoverned, default tier. Area o5-D lands with --land once every required check on bd194d3ffc is green, Test Core 1–10 included. A red check is a REWORK.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation security size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

1 participant